Go top
Paper information

Public perception on immigration and racial discrimination in Spain: a social media analysis using X data

B. Botas, J. Cifuentes, Y.A. Jiménez, M. Espinosa

Journal of Computational Social Science Vol. 9, nº. 1, pp. 25

Summary:

The increasing use of social media, particularly X (formerly Twitter), has enabled citizens to openly share their views, making it a valuable arena for examining public perceptions of immigration and its intersections with racial discrimination and xenophobia. This study analyzes Spanish digital debates from January 2020 to January 2023 through a mixed methodology that combines text pre-processing, semantic filtering of keywords, topic modeling, and sentiment analysis. A five-topic solution obtained through Latent Dirichlet Allocation (LDA) captured the main dimensions of the discourse: (1) economic and political debates on immigration, (2) international migration and refugee contexts, (3) racism and social discrimination, (4) insults, stereotypes, and xenophobic framings, and (5) small boat arrivals and maritime management. Sentiment analysis using a transformer-based model (roBERTuito) revealed a strong predominance of negativity across all topics, with sharp spikes linked to major migration crises, humanitarian emergencies, and highly mediatized cultural events. Qualitative readings of representative posts further showed that negativity was often articulated through invasion metaphors, securitarian framings, satire, and ridicule, indicating that hostility was not merely reactive but embedded in broader economic, political, and cultural registers. These findings demonstrate that discriminatory discourse in Spain is event-driven, becoming particularly salient during crises and symbolic moments, and underline the persistent role of social media in amplifying racialized exclusion and partisan polarization.


Spanish layman's summary:

Debates en X en España ene 2020–ene 2023 sobre inmigración trataron sobre política/economía, refugiados, racismo, además de estereotipos xenófobos. Predominó tono negativo, con picos en crisis y eventos virales, amplificando polarización.


English layman's summary:

Spanish debates on X Jan 2020–Jan 2023 about immigration focused on politics/economy, refugees, racism, and xenophobic stereotypes. Sentiment was mostly negative, spiking in crises and viral events, amplifying polarization.


Keywords: Social media · Discrimination · Immigration · Sentiment analysis · Topic modeling


JCR-JIF Impact Factor and WoS quartile: 2,300 - Q2 (2024)

DOI reference: DOI icon https://doi.org/10.1007/s42001-025-00459-8

Published on paper: 2026.

Published on-line: January 2026.



Citation:
B. Botas, J. Cifuentes, Y.A. Jiménez, M. Espinosa, "Public perception on immigration and racial discrimination in Spain: a social media analysis using X data", Journal of Computational Social Science, Vol. 9, nº. 1, pp. 25, 2026. [Online: January 2026] doi: 10.1007/s42001-025-00459-8

    Research topics:
  • Machine Learning and Advanced Analytics
  • Social inclusion and vulnerability
    Research groups:
  • Instituto de Investigación Tecnológica (IIT)
  • Innovación docente y Analytics (GIIDA)
    ODS:
  • Goal 10: Reducing inequalities
  • Goal 16: Peace, justice and strong institutions